<template>
  <div>
    <el-dialog title="检索" :visible.sync="dialogFormVisible">
      <el-form :model="form">
        <el-form-item label="产品名称" :label-width="formLabelWidth">
          <el-input v-model="form.brand_product_name" autocomplete="off" clearable />
        </el-form-item>
        <el-form-item label="品牌名称" :label-width="formLabelWidth">
          <el-select v-model="form.brand_id" placeholder="请选择品牌名称" clearable>
            <el-option v-for="item in brandList" :key="item.id" :label="item.brand_name" :value="item.id" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getBrandList } from '@/api/brand'
export default {
  data() {
    return {
      dialogFormVisible: false,
      form: {
        brand_product_name: '',
        brand_id: ''
      },
      formLabelWidth: '120px',
      brandList: []
    }
  },
  created() {
    this.getBrandListFun()
  },
  methods: {
    getBrandListFun() {
      const data = {
        p: 1,
        num: 10000,
        status: 1,
        brand_name: '',
        brand_login_name: ''
      }
      getBrandList(data).then(res => {
        console.log(res)
        this.brandList = res.list
      })
    },
    submit() {
      this.dialogFormVisible = false
      this.$emit('search', this.form)
    }
  }
}
</script>

<style lang="sass" scoped>

</style>
